﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class ContractBL
	{

		#region ***** Init Methods ***** 
		ContractDA objContractDA;
		public ContractBL()
		{
			objContractDA = new ContractDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get Contract by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>Contract</returns>
        public Contract GetByID(int id, int PersonalProfileID)
		{
            return objContractDA.GetByID(id, PersonalProfileID);
		}

		/// <summary>
		/// Get all of Contract
		/// </summary>
		/// <returns>List<<Contract>></returns>
		public List<Contract> GetList()
		{
			string cacheName = "lstContract";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objContractDA.GetList(), "Contract");
			}
			return (List<Contract>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of Contract
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetOld()
		{
			string cacheName = "dsContract";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objContractDA.GetDataSetOld(), "Contract");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}

        public DataSet GetDataSet(int PersonalProfileID)
        {
            string cacheName = "dsContract";
            ServerCache.Remove("dsContract",true);
            if (ServerCache.Get(cacheName) == null)
            {
                ServerCache.Insert(cacheName, objContractDA.GetDataSet(PersonalProfileID), "Contract");
            }
            return (DataSet)ServerCache.Get(cacheName);
        }
       
		/// <summary>
		/// Get all of Contract paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<Contract>></returns>
		public List<Contract> GetListPaged(int recperpage, int pageindex)
		{
			return objContractDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of Contract paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objContractDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new Contract within Contract database table
		/// </summary>
		/// <param name="obj_contract">Contract</param>
		/// <returns>key of table</returns>
		public int Add(Contract obj_contract)
		{
			ServerCache.Remove("Contract", true);
			return objContractDA.Add(obj_contract);
		}

		/// <summary>
		/// updates the specified Contract
		/// </summary>
		/// <param name="obj_contract">Contract</param>
		/// <returns></returns>
		public void Update(Contract obj_contract)
		{
			ServerCache.Remove("Contract", true);
			objContractDA.Update(obj_contract);
		}

		/// <summary>
		/// Delete the specified Contract
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("Contract", true);
			objContractDA.Delete(id);
		}
		#endregion
	}
}
